<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
<title>申请邮件审批</title>
<style type="text/css">
body {
    font-size:12px;
    width:594px;
    text-align:center;
}
.h1{
	font-size:14px;
	border-bottom:1px solid #4fa3d1;
	width:99%;
	padding:1px 0px;
}
.suc{
    width:500px;
    height:50px;
    margin-top:12px;
    padding:24px 0px 0px 0px;
    border:1px solid #5da60f;
    color:#009900;
    font-size:14px;
    background-color: #E4F9CE;
}
.fail{
    width:500px;
    height:25px;
    margin-top:12px;
    padding:24px;
    border:1px solid #e69a0a;
    color:#e71d02;
    font-size:14px;
    background-color: #fff3ce;
}
</style>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/interface/ExaminWFApprover.js"></script>
<script type="text/javascript" src="resource/js/hrm/common.js"></script>
<script type="text/javascript" src="resource/js/error.js"></script>
<script type="text/javascript" src="../resource/js/validator.js"></script>
<script type="text/javascript" src="../resource/js/util.js"></script>
<script language="JavaScript">
//审批动作；
function operat1(oper){
	var comments = document.getElementById("comments").value;
	if(oper == 'reject' && (comments == null || comments.length ==0)){
		alert("拒绝时必须填写备注！");
		return;
	}

	// 隐藏输入文本框和button；
	document.getElementById("inputFields").style.display = "none";
	document.getElementById("inputButton").style.display = "none";
	document.getElementById("closeButton").style.display = "block";

	var operate = oper;
	var employeeId = '<%=(String)request.getAttribute("employeeId")%>';
	var objId = '<%=(String)request.getAttribute("objId")%>';
	var securityNo = '<%=(String)request.getAttribute("securityNo")%>';
	var flowType = '<%=(String)request.getAttribute("flowType")%>';

	ExaminWFApprover.DWRwfObjOpSingle(operate, comments, employeeId, objId, securityNo, flowType, approveCallback);
}

// 回调函数；
function approveCallback(info){
	if(info.indexOf("SUCC:")>-1){
		document.getElementById("succSpan").innerHTML = "操作成功！";
		document.getElementById("succDiv").style.display = "block";
	}else{
		info = info.split(":")[1];
		document.getElementById("failSpan").innerHTML = info;
		document.getElementById("failDiv").style.display = "block";
	}
}

// 根据是否审批过显示页面内容；
function checkShow(){
	var statusError = '<%=(String)request.getAttribute("securityNoError")%>';
	if(statusError == 'true'){
		document.getElementById("failSpan").innerHTML = "验证码错误！请检查是否已经执行过该操作！";
		document.getElementById("failDiv").style.display = "block";
		document.getElementById("closeButton").style.display = "block";
	}else{
		document.getElementById("inputFields").style.display = "block";
		document.getElementById("inputButton").style.display = "block";
	}
}
</script>
</head>
<body onload="checkShow();">
    <img src="resource/images/login_top.gif"/>
	<div align="center" style="width:594px; background-image:url(resource/images/login_bg.gif);">
	    <div class="suc" id="succDiv" style="display:none">
	        <img src="resource/images/success.gif"/>&nbsp;<span id="succSpan"></span>
	    </div>
	    <div class="fail" id="failDiv" style="display:none">
	        <img src="resource/images/error1.gif"/>&nbsp;<span id="failSpan"></span>
	    </div>
	    <div id="inputFields" style="display:none">
		    <%if("leaverequest".equals((String)request.getAttribute("flowType"))){ %> <h1>请假审批</h1> <%} %>
		    <%if("overtimerequest".equals((String)request.getAttribute("flowType"))){ %> <h1>加班审批</h1> <%} %>
		    <table width="100%">
			    <tr>
				    <td align="right" width="30%">备注:</td>
				    <td align="left" width="70%"><textarea id="comments" name="comments" rows="4" cols="35" onkeyup="if(this.value.length>255){this.value=this.value.substring(0, 255);}"></textarea></td>
			    </tr>
		    </table>
	    </div>
	    <div id="inputButton" style="display:none">
	    	<br>
	        <input id="btn_approve" class="button" type="button" value="批准" onclick="operat1('approve');" />  
	        <input id="btn_reject" class="button" type="button" value="拒绝" onclick="operat1('reject');" />
	    </div>
	    <div id="closeButton" style="display:none">
	    	<br>
	        <input id="btn_close" class="button" type="button" value="关闭" onclick="window.close();" />  
	    </div>
	    <br>
	</div>
    <img src="resource/images/login_bot.gif"/>
</body>
</html>